#ifndef _MCL_BITSTREAM_READER
#define _MCL_BITSTREAM_READER
#include <vector>
#include "mcl_bitstream.hpp"

namespace mcl
{
class BitstreamReader : public Bitstream
{
	BitstreamReader(std::vector<char> &vec);
	virtual ~BitstreamReader();
	virtual bool byte_aligned();
	virtual bool more_data_in_byte_stream();
	virtual bool more_rbsp_data();
	virtual bool more_rbsp_trailing_data();
	virtual void rbsp_trailing_bits();
	virtual unsigned int next_bits(unsigned int n);
	virtual unsigned int read_bits(unsigned int n);
	// Read unsigned exponential golomb encoded bits
	virtual unsigned int read_bits_ue();
	// Read signed exponential golomb encoded bits
	virtual signed int read_bits_se();
protected:
	std::vector<char> &m_vec;
	// Once data has been read in, step the bitstream bit position forward.
	virtual void step(unsigned int bits);
	// Return an integer containing a number of bits that have been peeked.
	virtual unsigned int peek(unsigned int bits);
	// The number of bits necessary to reach the next byte alignment.
	virtual unsigned int bitsToAlign();
	// The current offset, in bytes, of the byte stream
	size_t m_bytePos;
	// The current offset, in bits, of the bitstream
	unsigned int m_bitPos;
};

};

#endif